import EventEmitter from 'events'

class GameStore extends EventEmitter {
    constructor() {
        super();
        this.visible = false;
    }

    changeModalVisible(visible) {
        this.visible = visible;
    }

    emitChange() {
        this.emit('change')
    }

    //监听函数，当有变化时调用注册的回调方法
    addChangeListener(callback) {
        this.on('change', callback)
    }

    //remove监听函数
    removeChangeListener(callback) {
        this.removeListener('change', callback)
    }
}

let gameStore = new GameStore();
export default gameStore;